﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using EPiBoost.Core.Infrastructure.Interfaces.Repositories;
using EPiBoost.Core.Infrastructure.Repositories;

namespace EPiBoost.Core
{
	public class Global : EPiServer.Global
	{
		// todo : move this, and use DI
		internal static IExceptionLogRepository ExceptionLogRepository
		{
			get
			{
				const string key = "EPiBoost.IExceptionLogRepository.Instance";
				var repo = EPiServer.CacheManager.Get(key) as IExceptionLogRepository;
				if (repo == null)
				{
					var repoType = Type.GetType(Configuration.Core.ErrorHandling.ExceptionLogRepositoryTypeName);
					repo = Activator.CreateInstance(repoType, null) as IExceptionLogRepository;
					EPiServer.CacheManager.Add(key, repo);
				}
				return repo;
			}
		}

		protected Global() : base()
		{
			
		}

	}
}
